#include "yigsynth.h"
#include <QDebug>

YigSynth::YigSynth(sc::Synth *synth, QString key, int audioInBus, int audioOutBus, int modInBus) :
    mSynth(synth),
    mKey(key),
    mParam1(0),
    mParam2(0),
    mAudioInBus(audioInBus),
    mAudioOutBus(audioOutBus),
    mModInBus(modInBus)
{

}

YigSynth::~YigSynth()
{
    delete mSynth;
}

QString YigSynth::getKey()
{
    return mKey;
}

int YigSynth::getAudioInBus()
{
    return mAudioInBus;
}

int YigSynth::getAudioOutBus()
{
    return mAudioOutBus;
}

int YigSynth::getModInBus()
{
    return mModInBus;
}

QString YigSynth::getSynthDefName()
{
    return mSynth->getDefName();
}

void YigSynth::free()
{
    mSynth->set("gate", 0);
    //mSynth->free();
}

void YigSynth::setParam1(float param1)
{
    mParam1 = param1;
    mSynth->set("paramOne", mParam1);
}

void YigSynth::setParam2(float param2)
{
    mParam2 = param2;
    mSynth->set("paramTwo", mParam2);
}

void YigSynth::setParam(QString mapKey, YigSynthGraphic::ParamType paramType, float value)
{
    //qDebug() << "PARAM CHANGED!!!!!: " << paramType;
    if(paramType == YigSynthGraphic::Param1)
    {
        setParam1(value);
    }

    else
    {
        setParam2(value);
    }
}

void YigSynth::setAudioInBus(int audioInBus)
{
    mAudioInBus = audioInBus;
    mSynth->set("audioIn", mAudioInBus);
}

void YigSynth::setAudioOutBus(int audioOutBus)
{
    mAudioOutBus = audioOutBus;
    mSynth->set("audioOut", mAudioOutBus);
}

void YigSynth::setModInBus(int modInBus)
{
    mModInBus = modInBus;
    mSynth->set("modIn", mModInBus);
}
